package com.zkj.controller.user;

import com.zkj.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @author: zhangKaiJun
 * @createTime：2024/9/2
 * @description：
 */
@RestController
@RequestMapping("/user/shop")
@Component("userShopController")
@Slf4j
@Api(value = "ShopController", tags = "商户店铺管理")
public class ShopController {

    public static final String SHOP_STATUS = "shop_status";

    @Autowired
    private RedisTemplate redisTemplate;

    // 修改商铺运营状态
    @PutMapping("/{status}")
    @ApiOperation(value = "修改店铺状态")
    public Result<String> updateShopStatus(@PathVariable Integer status) {
        log.info("修改店铺状态为：{}", status);
        //修改店铺状态
        redisTemplate.opsForValue().set(SHOP_STATUS, status);
        return Result.success("修改成功");
    }

    @GetMapping("/status")
    @ApiOperation(value = "获取店铺状态")
    public Result<Integer> getShopStatus() {
        Integer shopStatus =(Integer)  redisTemplate.opsForValue().get(SHOP_STATUS);
        log.info("获取店铺状态 {}", shopStatus);
        return Result.success(shopStatus);
    }

    @GetMapping("/getMerchantInfo")
    @ApiOperation(value = "获取店铺状态")
    public Result<Integer> getMerchantInfo() {
        Integer shopStatus = (Integer)  redisTemplate.opsForValue().get(SHOP_STATUS);
        log.info("获取店铺状态 {}", shopStatus);
        return Result.success(shopStatus);
    }


}
